package com.sgffsg.learn.lib

import com.sgffsg.learn.lib.test.Person
import com.sgffsg.learn.lib.utils.name
import com.sgffsg.learn.lib.utils.plus


class MyClass {
    lateinit var level: String
    val name: String by lazy{
        "bbb"
    }

    var age: Int = 0
        set(value) { field = value }
        get() { return field }

    companion object {
        const val VERSION = 1
    }

    fun test1() {
        val anInt: Int = 5
        System.out.println("anInt = $anInt, VERSION = $VERSION")
    }

    fun test2() {
        val ccLong: Long = 5
        System.out.println("ccLong = $ccLong, VERSION = ${TestObject.NAME}")
    }

    fun test3() {
        val str = "hello".plus(" world")
        System.out.println("str = $str")
    }

    fun test4() {
        ::level.isInitialized
    }

    fun test5() {
        println("-------test5------")
        val a = 122
        val b = 122
        println("a == b = ${a == b}")
        println("a === b = ${a === b}")
        val c = 1290
        val d = 1290
        println("c == d = ${c == d}")
        println("c === d = ${c === d}")

        val s1 = "122"
        val s2 = "122"
        println("s1 == s2 = ${s1 == s2}")
        println("s1 === s2 = ${s1 === s2}")

        val p1 = Person("张三",23)
        val p2 = Person("张三",23)
        println("p1 == p2 = ${p1 == p2}")
        println("p1 === p2 = ${p1 === p2}")

    }

}

fun main(args: Array<String>) {
    val myClass = MyClass()
    myClass.test1()
    myClass.test2()
    myClass.test3()
    myClass.test5()
    println("myClass.name = ${myClass.name}")
}